/**************************************************************************
File:        positiondsp.h
Description:

Copyright:   (C) 2001 by ZJ Laczik
Email:       Zsolt.Laczik@eng.ox.ac.uk
****************************************************************************
Change log:
   begin      Fri Mar 16 2001
   15/2/2012	QT4 update
***************************************************************************/

#ifndef POSITIONDSP_H
#define POSITIONDSP_H

#include <QWidget>
#include <QEvent>

/**
  *@author ZJ Laczik
  */

class PositionDsp : public QWidget  {
    Q_OBJECT
public:
    PositionDsp(QWidget *parent=0);
    ~PositionDsp();
    void paintEvent(QPaintEvent* event);
    void keyPressEvent ( QKeyEvent * e );
    void keyReleaseEvent ( QKeyEvent * e );
    void enterEvent( QEvent *e );
    void leaveEvent( QEvent *e );
    void mousePressEvent( QMouseEvent *e );
    void mouseReleaseEvent( QMouseEvent * );
    void mouseDoubleClickEvent( QMouseEvent * );
    void mouseMoveEvent( QMouseEvent *e );
    void resizeEvent( QResizeEvent *e );
public slots:
    void SetXPos(float pos);
    void SetYPos(float pos);
    void SetZPos(float pos);
    void SetPos(float x, float y, float z);
    void SetXLimits(float min, float max);
    void SetYLimits(float min, float max);
    void SetZLimits(float min, float max);
    void SetZoom(float zoom) {
        if (zoom>=0.1 && zoom<=1000.0) mZoom = zoom;
        repaint();
    };
    void EnableMoves(bool state);
signals:
    void MoveTo(float x, float y, float z);
    void Move(int axis, float distance);
private:
    float mMultiplier;
    int mW,mH;
    int mAxis;
    float mZoom;
    float mDir;
    float mXPos, mYPos, mZPos;
    float mMinX, mMaxX;
    float mMinY, mMaxY;
    float mMinZ, mMaxZ;
    float mMin, mMax;
    float mRM[3][3];
    QRect mUpdateRect;
    void Redraw();
    void Set3DRotation(float a, float b, float c);
    void CalcMaxRange();
    void CalcEndPoints();
    void World2Scr(float x, float y, int &nx, int &ny);
    void Rotate3D(float x, float y, float z, float &nx, float &ny, float &nz);
    void Draw3DLine(QPainter &p, float xx1, float yy1, float zz1, float xx2, float yy2, float zz2);
    QPoint mZZ,mXP,mXM,mYP,mYM,mZP,mZM;
    bool mEnableMoves;
};


#endif
